//
//  WiFiSendManager.m
//  LJLAirCleanr
//
//  Created by make on 2017/4/14.
//  Copyright © 2017年 make. All rights reserved.
//

#import "WiFiSendManager.h"
#import "NSString+FIDMatch.h"

@implementation WiFiSendManager

+ (void)turnOnPowerWithMacAddres:(NSString *)macAddress value:(NSString *)value {
    [self sendCommandCode:@"1082" command:value macAddress:macAddress];

}

+ (void)turnOnOffLockWithMacAddres:(NSString *)macAddress value:(NSString *)value {
    [self sendCommandCode:@"1005" command:value macAddress:macAddress];

}

+ (void)turnOnOffLightWithMacAddres:(NSString *)macAddress value:(NSString *)value {
    [self sendCommandCode:@"1009" command:value macAddress:macAddress];

}

+ (void)turnOnOffSleepWithMacAddres:(NSString *)macAddress value:(NSString *)value {
    [self sendCommandCode:@"1004" command:value macAddress:macAddress];

}

+ (void)settingTemeratureWithMacAddres:(NSString *)macAddress value:(NSString *)value{
    [self sendCommandCode:@"1002" command:value macAddress:macAddress];

}

+ (void)settingTimeWithMacAddres:(NSString *)macAddress value:(NSString *)value{
    [self sendCommandCode:@"1003" command:value macAddress:macAddress];

}

+ (void)syncInfo:(NSString *)macAddress
{
    [self sendCommandCode:@"1001" command:@"00" macAddress:macAddress];
}



+ (void)toggleModel:(NSString *)macAddress value:(NSString *)value{
    [self sendCommandCode:@"1080" command:value macAddress:macAddress];

}


+ (void)toggleSpeed:(NSString *)macAddress value:(NSString *)value{
    
    [self sendCommandCode:@"1081" command:value macAddress:macAddress];

}

+ (void)timingSetting:(NSString *)macAddress weekStr:(NSString *)weekStr beginTime:(NSArray *)beginArray runTime:(NSArray *)runArray speed:(NSString *)speed isOn:(NSString *)isOn{

    
    NSInteger hours = [beginArray.firstObject integerValue];
    NSInteger minutes = [beginArray.lastObject integerValue];
    
    NSInteger runHours = [runArray.firstObject integerValue];
    NSInteger runMinutes = [runArray.lastObject integerValue];
    
    NSString *hour = [NSString decimalToHexadecimal:hours];
    NSString *minute = [NSString decimalToHexadecimal:minutes];
    
    NSString *runHour = [NSString decimalToHexadecimal:runHours];
    NSString *runMinute = [NSString decimalToHexadecimal:runMinutes];

    NSString *value = [NSString stringWithFormat:@"%@%@%@%@%@%@%@",isOn,weekStr,speed,hour,minute,runHour,runMinute];
    
    NSLog(@"value ==== %@",value);

    [self sendCommandCode:@"1082" command:value macAddress:macAddress];
}

+ (void)getTiming:(NSString *)macAddress{
    [self sendCommandCode:@"1002" command:@"" macAddress:macAddress];
}

+ (void)sendCommandCode:(NSString *)code command:(NSString *)command macAddress:(NSString *)macAddress
{
    [[DTCloudManager defaultJNI_iOS_SDK]sendCommandByFunctionCode:code functionCommand:command deviceMacAddress:macAddress deviceType:DeviceUsedByWiFi protocolType:DTSDKProtocolTypeThird];
}
@end
